<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>采购单</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/public/windowalert";
		
		function createSearch(){
			init(1,8,'100,100,100,100,100,100,100,100','10%');
			addCommon(0,0,"lable","pi编号：");
			addCommon(0,1,"txtlike","zd012PiCode");
			addCommon(0,2,"lable","采购编号：");
			addCommon(0,3,"txtlike","zd020Code");
			addCommon(0,4,"lable","单据状态：");
			addCommon(0,5,"selectEnum","zd011Status","<option></option><option value='3'>审核完成</option><option value='4'>部分入库</option>"+
			"<option value='5'>完成入库</option><option value='6'>自动入库虚礼仓</option>");
		}
		
		function searchAP(){
			multipleSearch("#table1",true,"",basic_Url+"/purchaseList.do");
		}
		var grid;
		$(function(){
				grid = $("#table1").ligerGrid({
		        columns: [    { display: 'id', name: 'id',hide:1,width:1},
		                      { display: 'pi编号', name: 'zd012PiCode', width: 200 },
			                  { display: '采购编号', name: 'zd020Code', width: 200 },
			                  { display: '单据状态', name: 'zd011Status', width: 200, render : function(item){
			                	  if(item.zd011Status=='PHS_SAVE'){
			                		  return '草稿';
			                	  }else if(item.zd011Status=='PHS_SUBMIT'){
			                		  return '已提交';
			                	  }else if(item.zd011Status=='PHS_AUDIT'){
			                		  return '二级审核';
			                	  }else if(item.zd011Status=='PHS_APPROVE'){
			                		  return '审核完成';
			                	  }else if(item.zd011Status=='PHS_SAVE'){
			                		  return '已退回';
			                	  }else{
			                		  return '已完结';
			                	  }
			                  }},
			                  { display: '采购日期', name: 'zd019OrderDate', width: 150,
			                	  render: function (item){
			                		  var odate=new Date(item.zd019OrderDate);
			                		  return formatDate(odate,"yyyy-MM-dd");
			                  }},
			                  { display: '支付方式id', name: 'zd005PayId', hide : true },
			                  { display: '支付方式code', name: 'zd005PayCode', hide : true },
			                  { display: '支付方式', name: 'zd005PayName', hide: true },
			                  { display: '采购部门id', name: 'zd008DeptId', hide : true },
			                  { display: '采购部门code', name: 'zd009DeptCode', hide : true },
			                  { display: '采购部门', name: 'zd010DeptName', width: 200 },
			                  { display: '创建人', name: 'bizCreatorName', width: 150},
			                  { display: '创建日期', name: 'bizCreatorDate', width: 150,
			                	  render: function (item){
			                		  var cdate=new Date(item.bizCreatorDate);
			                		  return formatDate(cdate,"yyyy-MM-dd");
			                	  }},
			                  { display: '备注', name: 'zd017Remark', width: 150 } ],  usePager: true,pageSize:30,
		                      url : basic_Url+"/purchaseList.do",
		                      width: "100%", height:"98%", checkbox: true, checkbox: true,rownumbers:true,      
		                      onSelectRow : function (data, rowindex, rowobj){
		                    	  ShowIframeDialog("","查看采购订单的详细记录","/public/windowalert/materialListForPurchase.do?id="+data.id,"100%","100%");
		                       		var rows= grid.getSelectedRows();
		                       		$(rows).each(function(){
		                       			if(this.id!=data.id){
		                       				grid.unselect(this.__index);
		                       			}
		                       		});
		                       	
		                      }
		                  });
			$("#pageloading").hide();
		});
		
		function getSelected(){
			var rows = grid.getCheckedRows();
			 return rows;
		}
		
		function Close(){
			CloseDialog();
		}
		//按回车 ，查询
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
	</script>
	
  </head>
 <body style="padding:10px" onload="createSearch()">  
       <div id="layout1">
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
    </body>
</html>